import { defineStore } from "pinia";
import { getHomeHotSuggests, getHomeCategories, getHomeHouselist} from "@/service/index";


const useHomeStore = defineStore("home", {
    state: () => ({
        hotSuggests: [],
        categories: [],
        currentPage: 1, 
        houseList: []
    }
    ),
    actions: {  
       async fetchHotSuggestsData() {
            const res = await getHomeHotSuggests()
            this.hotSuggests = res.data
        },
        async fetchCategories() {
            const res = await getHomeCategories()
            this.categories = res.data
        },
        async fetchHouselistData() {
            const res = await getHomeHouselist(this.currentPage)
            this.houseList.push(...res.data)
            this.currentPage++
        }
    }
})
export default useHomeStore